<?php

class TinyMVCCache {
	private $client = null;

	public function __construct($client = null) {
		$this->client = $client;
	}

	public function getClient() {
		return $this->client;
	}

	public function get($key) {
		return $this->client->get($key);
	}

	public function set($key, $value, $ttl = 0) {
		return $this->client->set($key, $value, $ttl);
	}

	public function replace($key, $value, $ttl = 0) {
		return $this->client->replace($key, $value, $ttl);
	}

	public function delete($key) {
		$this->client->delete($key);
	}

	/**
	 * check whether cache system is up and running
	 * @return bool
	 */
	public function isEnabled() {
		$this->delete('CacheTestKey');
		$this->set('CacheTestKey', true, 10);

		return $this->get('CacheTestKey') ? true : false;
	}
}
